package com.senlingspace.web.controller.headquarters;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.system.domain.SlkjPos;
import com.senlingspace.system.service.ISlkjPosService;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.common.core.page.TableDataInfo;

/**
 * 票务系统Controller
 * 
 * @author wangliang
 * @date 2024-07-15
 */
@RestController
@RequestMapping("/system/pos")
public class SlkjPosController extends BaseController
{
    @Autowired
    private ISlkjPosService slkjPosService;

    /**
     * 查询票务系统列表
     */
    @PreAuthorize("@ss.hasPermi('system:pos:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlkjPos slkjPos) {
        List<SlkjPos> list = slkjPosService.selectSlkjPosList(slkjPos);
        return getDataTable(list);
    }

    /**
     * 导出票务系统列表
     */
    @PreAuthorize("@ss.hasPermi('system:pos:export')")
    @Log(title = "票务系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlkjPos slkjPos)
    {
        List<SlkjPos> list = slkjPosService.selectSlkjPosList(slkjPos);
        ExcelUtil<SlkjPos> util = new ExcelUtil<SlkjPos>(SlkjPos.class);
        util.exportExcel(response, list, "票务系统数据");
    }

    /**
     * 获取票务系统详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pos:query')")
    @GetMapping(value = "/{posId}")
    public AjaxResult getInfo(@PathVariable("posId") Long posId)
    {
        return success(slkjPosService.selectSlkjPosByPosId(posId));
    }

    /**
     * 新增票务系统
     */
    @PreAuthorize("@ss.hasPermi('system:pos:add')")
    @Log(title = "票务系统", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlkjPos slkjPos)
    {
        return toAjax(slkjPosService.insertSlkjPos(slkjPos));
    }

    /**
     * 修改票务系统
     */
    @PreAuthorize("@ss.hasPermi('system:pos:edit')")
    @Log(title = "票务系统", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlkjPos slkjPos)
    {
        return toAjax(slkjPosService.updateSlkjPos(slkjPos));
    }

    /**
     * 删除票务系统
     */
    @PreAuthorize("@ss.hasPermi('system:pos:remove')")
    @Log(title = "票务系统", businessType = BusinessType.DELETE)
	@DeleteMapping("/{posIds}")
    public AjaxResult remove(@PathVariable Long[] posIds)
    {
        return toAjax(slkjPosService.deleteSlkjPosByPosIds(posIds));
    }
}
